<template>
	<view class="wp">
		<view class="list">
			<view class="item" v-for="item in list">
				<image :src="item.thumb"></image>
				<view class="info">
					<view class="tit">{{item.title}}</view>
					<view class="tips">已售{{item.sales}}</view>
					<view class="price">
						<view class="p_total">
							<view class="p_new"><text class="small">￥</text>{{item.saleprice}}</view>
							<view class="p_old">￥{{item.marketprice}}</view>
						</view>
						<view class="btn" @click="$navTo('./groupbuy?id='+item.id)">购买</view>
					</view>
				</view>
			</view>
		</view>
		<view class="empty_loading">
			<image v-if="isloading" src="/static/business/loading.gif" mode=""></image>
			<text v-if="isempty">到底了~</text>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex'
	export default {
		data() {
			return {
				list:[],
				page: 0,
				isloading: false,
				isempty: false,
			};
		},
		async onLoad() {
			// await this.$onLaunched;
			this.getList();
		},
		computed: {
		  	...mapState(['Location'])
		},
		onReachBottom() {
			this.getList();
		},
		methods: {
			getList(){
				this.page++;
				this.isloading = true;
				this.isempty = false;
				let obj = {
					...this.Location,
					...{
						page: this.page
					}
				}
				this.$axios('market/lists','POST','shop',obj).then(res=>{
					this.isloading = false;
					if(res.data.code == 200){
						this.list = [...this.list,...res.data.data];
						this.isempty = res.data.data == null || res.data.data.length <= 0;
					}
				})
			},
		}
	}
</script>

<style lang="scss">
page{
	background: linear-gradient( 180deg, #F1FCE1 0%, #F8FEF9 100%);
	padding-bottom: 40rpx;
}
.wp{
	padding: 20rpx;
}
.list{
	.item{
		display: flex;
		margin-bottom: 20rpx;
		background: #fff;
		border-radius: 12rpx;
		padding: 20rpx;
		image{
			width: 256rpx;
			height: 255rpx;
			border-radius: 12rpx;
		}
		.info{
			flex: 1;
			padding-left: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.tit{
				font-weight: 600;
			}
			.tips{
				font-size: 24rpx;
				color: #999999;
				margin-bottom: 30rpx;
			}
			.price{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.p_total{
					display: flex;
					align-items: center;
					.p_new{
						font-weight: 600;
						font-size: 40rpx;
						color: #FD3155;
						margin-right: 20rpx;
						.small{
							font-size: 24rpx;
						}
					}
					.p_old{
						font-size: 20rpx;
						color: #999999;
						text-decoration: line-through;
					}
				}
				.btn{
					width: 168rpx;
					height: 66rpx;
					background: linear-gradient( 90deg, #7BB624 0%, #2D8020 100%);
					border-radius: 33rpx;
					color: #FFFFFF;
					font-weight: 600;
					line-height: 66rpx;
					text-align: center;
				}
			}
		}
	}
}
</style>
